using System;
using System.Collections.Generic;
using System.Text;

using System.Web.UI;
using System.Web.UI.WebControls;

using Pampa.CRUD.UI.CustomControls;

namespace Pampa.CRUD.Configuration
{
    public class CheckBoxItem : EditItem
    {
        CheckBox checkbox = new CheckBox();

        public CheckBoxItem() : base()
        {
        }

        public CheckBoxItem(CheckBoxItem sourceItem) : base(sourceItem)
        {
        }

        #region Properties

        public override Type ValueTypeDefault
        {
            get { return typeof(System.Boolean); }
        }

        public override ItemType ItemType 
        {
            get { return ItemType.Checkbox; }
        }

        public override Control Control
        {
            get
            {
                checkbox.Text = "";
                checkbox.CssClass = "checkBox";
                checkbox.Enabled = this.Enabled;

                if (!String.IsNullOrEmpty(this.OnClientChange))
                    checkbox.Attributes.Add("onclick", this.OnClientChange);

                if (this.Value != null)
                    checkbox.Checked = bool.Parse(this.Value.ToString());

                return checkbox;
            }
        }

        #endregion

        #region Public Functions

        public override VisibleItem Clone()
        {
            return new CheckBoxItem(this);
        }

        #endregion
    }
}
